# Generate types for Swift, build the shared library as a Swift package
build: typegen package

# clean, rebuild the Xcode project and build
rebuild: clean build generate-project

# build and run Xcode
dev: build generate-project
    xed .

# remove all the generated artifacts
clean:
    cargo clean
    rm -rf *.xcodeproj generated

# rebuild the Xcode project from the `project.yaml` file
generate-project: build
    xcodegen

# generate types for Swift
typegen:
    cargo build --package shared --features uniffi
    RUST_LOG=info cargo run \
        --package shared \
        --bin codegen \
        --features codegen,facet_typegen \
        -- \
            --language swift \
            --output-dir generated

# use `cargo swift` to build the shared library as a Swift package
[working-directory('../shared')]
package:
    cargo swift package \
        --name Shared \
        --platforms ios \
        --lib-type static \
        --features uniffi
    rm -rf generated
    mkdir -p ../iOS/generated/Shared
    cp -r Shared/* ../iOS/generated/Shared/
    rm -rf Shared
